package com.manage.base.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.manage.base.dao.IBaseDao;
import com.manage.base.service.IBaseService;

@Service("baseService")
public class BaseServiceImpl<T>
		implements IBaseService<T> {

	@Autowired
	protected IBaseDao<T> baseDao;

	public int add(T t) throws Exception {
		return baseDao.add(t);
	}

	public boolean exist(T t) throws Exception {
		return baseDao.exist(t);
	}

	public int update(T t) throws Exception {
		return baseDao.update(t);
	}

	public int delete(T t) throws Exception {
		List<T> list = select(t);
		if (list.size() > 0) {
			return baseDao.delete(t);
		} else {
			return 0;
		}

	}

	public List<T> select(T t) throws Exception {
		return baseDao.select(t);
	}

	@Override
	public int insert(T t) throws Exception {
		return add(t);
	}

	@Override
	public T selectOne(T t) throws Exception {
		return baseDao.selectOne(t);
	}

	@Override
	public int selectCount(T t) throws Exception {
		return baseDao.selectCount(t);
	}

	@Override
	public T selectById(int parseInt) throws Exception {
		return baseDao.selectById(parseInt);
	}

	@Override
	public List<T> selectList(T t) throws Exception {
		return baseDao.selectList(t);
	}
}
